#ifndef FLUID_H
#define FLUID_H

class Fluid {

	// Fluid Simulation Variables
	int sideLength_; // How many cells wide and high. (N)
	float diffusion_;
	float *density_;
	float *previousDensity_;

	void allocate() {
		int size = (sideLength_ + 2) * (sideLength_ + 2);

		density_ = (float*)malloc(size * sizeof(float));
		previousDensity_ = (float*)malloc(size * sizeof(float));
	} // allocate()

	

public:
	Fluid() {}

	void initialize(int sideLength, float diffusion) {
		sideLength_ = sideLength;
		diffusion_ = diffusion;

		allocate();
		clearData();		
	} // initialize()

	void clearData() {
		int size = (sideLength_ + 2) * (sideLength_ + 2);

		for (int i = 0; i != size; ++i) {
			density_[i] = 0.0f;
			previousDensity_[i] = 0.0f;
		}
	} // clearData()

	float *getDensity() {return density_;}
	float *getPreviousDensity() {return previousDensity_;}

	void setPreviousDensity(int index, float value) {previousDensity_[index] = value;}
	void setDensity(int index, float value) {density_[index] = value;}

	void setDiffusion(float d) {diffusion_ = d;}
	float getDiffusion() {return diffusion_;}

	void update(float deltaTime, float *velocityX, float *velocityY) {
		FluidSolver::densityStep(sideLength_, density_, previousDensity_, velocityX, velocityY, diffusion_, deltaTime);
	} // update()
}; // Fluid



#endif // FLUID_H